#include "stdafx.h"
#include "ChipGroup.h"

CChipGroup::CChipGroup(void)
{
	m_vBelongedChip.reserve(7);
	m_bIsdel = false;
	m_eGrouplevel = nolevel;
}

CChipGroup::~CChipGroup(void)
{
}

void CChipGroup::initialize(PLAYER owner)
{
	m_nOwner = owner;
	
	for(int i = 0; i < 96; i++)
	{
		LUT_CHIP_IN[i] = false;
	}
}

bool CChipGroup::isdel(void)
{
	return m_bIsdel;
}

void CChipGroup::setDelMarking(void)
{
	m_bIsdel = true;
}

void CChipGroup::addChip(vector<int> chiplist)
{
	int temp;

	while(chiplist.empty() == false)
	{
		temp = chiplist[0];
		chiplist.erase(chiplist.begin());

		if( LUT_CHIP_IN[temp] == false )
		{
			m_vBelongedChip.push_back(temp);
			LUT_CHIP_IN[temp] = true;
		}
	}
}

void CChipGroup::deleteChip(vector<int> chiplist)
{
	int temp;

	while(chiplist.empty() == false)
	{
		temp = chiplist[0];
		chiplist.erase(chiplist.begin());

		if( LUT_CHIP_IN[temp] == true )
		{
			for(unsigned int i = 0; i < m_vBelongedChip.size(); i++)
			{
				if( m_vBelongedChip[i] == temp )
				{
					m_vBelongedChip.erase(m_vBelongedChip.begin() + i);
					break;
				}
			}

			LUT_CHIP_IN[temp] = false;
		}
	}
}

void CChipGroup::setOwner(PLAYER owner)
{
	m_nOwner = owner;
}

void CChipGroup::setGrouplevel(GROUPLEVEL grplevel)
{
	m_eGrouplevel = grplevel;
}

GROUPLEVEL CChipGroup::getGrouplevel(void)
{
	return m_eGrouplevel;
}

vector<int> CChipGroup::getBelongedChipVec(void)
{
	return m_vBelongedChip;
}

int CChipGroup::getGrpsize(void)
{
	return m_vBelongedChip.size();
}

PLAYER CChipGroup::getOwner(void)
{
	return m_nOwner;
}